<template>
  <div :data-theme="themeStore.theme.dark ? THEMES.DARK : THEMES.LIGHT" class="theme bg-gradient-to-r">
    <Header/>
    <NuxtPage/>
    <AnnScrollToTop/>
    <Footer/>
  </div>
</template>
<script setup lang="ts">
import {THEMES, useThemeStore} from "~/store/theme";
import type {BannerState} from "~/types/banner";
import {useBannerStore} from "~/store/banner";
import {queryDailyImageList} from "~/api/image";

const themeStore = useThemeStore();
// 创建 useBanners 实例，并传入 images 数据
const bannersStore = useBannerStore();
const getDailyImage = async () => {
  // 获取每日图片列表
  const {data: res} = await useAsyncData("queryDailyImageList", () =>
      queryDailyImageList()
  );
  bannersStore.banners = res.value?.data as BannerState[]
}
getDailyImage()


const messages = [
  `Uncaught NotFoundError: Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node.`, // chromium based
];
if (typeof window !== "undefined") {
  window.addEventListener("error", (ev) => {
    if (messages.includes(ev.message)) {
      ev.preventDefault();
      window.location.reload();
    }
  });
}

</script>
